Shared-memory computer systems allow multiple concurrent threads of execution to access shared memory locations. Unfortunately, writing correct multi-threaded programs is difficult due to the complexities of coordinating concurrent memory access.
Traditionally, to ensure program correctness, programmers have used locks or other mutual exclusion mechanisms for coordinating access to shared memory locations. For example, using traditional locks, a thread may be configured to acquire and hold a lock on each memory location to which it needs exclusive access. While the thread holds the lock, no other thread may acquire the lock, and therefore, no other thread may access the memory location protected by that lock. However, traditional locking techniques are vulnerable to various pitfalls, including dead-lock, race conditions, priority inversions, software complexity, and performance limitations.
An alternative approach to concurrency control is transactional memory. In a transactional memory programming model, a programmer may designate a section of code (i.e., an execution path or a set of program instructions) as a “transaction” which should be executed atomically with respect to other threads of execution. For example, if the transaction includes two memory store operations, then the transactional memory system ensures that all other threads may only observe either the cumulative effects of both memory operations or of neither, but not the effects of only one. In addition to a simplified programming model, transactional memory systems can also increase application performance since they may allow finer grained memory sharing than do traditional locks.
Various transactional memory systems have been proposed in the past, including those implemented in software, in hardware, or in a combination thereof. However, many previous concepts and implementations are bound by various limitations. For example, software-based transactional memory systems (STMs) suffer an undesirable performance overhead while hardware proposals (HTMs) may be prohibitively complex to implement.